/*
 * Created by SharpDevelop.
 * User: c0148643
 * Date: 11/05/2010
 * Time: 12:41
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Data;
using System.Data.SQLite;

namespace pontoIndividual
{
	/// <summary>
	/// Description of conexao.
	/// </summary>
	public class conexao : IDisposable
	{
		public string strConn = "Data Source=pontodb.db;Version=3;";
		public SQLiteConnection conn;
		public string errors = string.Empty;
		
		public conexao() {
			conn = new SQLiteConnection(strConn);			
		}
		
		public bool open() {
			
			if (conn.State == ConnectionState.Open)
				return true;
			
			try {
				
				conn.Open();
			} catch (SQLiteException exc) { 
				
				errors += exc.Message;
				return false;
			}
			
			return true;
		}
		
		public void close() {
			
			try {
				conn.Close();
				//conn.Dispose();
			} catch (Exception exc) {
			}
			
		}
		
		public void Dispose() {
			
			try {
				
				conn.Close();
				conn.Dispose();
			} catch (Exception exc) { }
			
		}
		
	}
}
